<template>
  <a-form-item :name="['dataSource', 'field']" label="字段名称">
    <jnpf-tree-select v-model:value="dataSource.field" lastLevel lastLevelKey="children" :options="dataSetList" :fieldNames="{ value: 'jnpfId' }" />
  </a-form-item>
  <a-form-item :name="['dataSource', 'polymerizationType']" label="聚合方式">
    <jnpf-select v-model:value="dataSource.polymerizationType" :options="polymerizationTypeOptions" />
  </a-form-item>
  <a-form-item v-if="dataSource.polymerizationType === '3'" :name="['dataSource', 'summaryType']" label="汇总方式">
    <jnpf-select v-model:value="dataSource.summaryType" :options="summaryTypeOptions" />
  </a-form-item>
  <a-form-item v-else :name="['dataSource', 'fillDirection']" label="填充方向">
    <a-radio-group v-model:value="dataSource.fillDirection">
      <a-radio value="portrait">纵向</a-radio>
      <a-radio value="landscape">横向</a-radio>
    </a-radio-group>
  </a-form-item>
  <a-form-item :name="['dataSource', 'leftParentCellType']" label="左父格">
    <jnpf-select v-model:value="dataSource.leftParentCellType" :options="cellTypeOptions" />
  </a-form-item>
  <template v-if="dataSource.leftParentCellType === 'custom'">
    <a-form-item :name="['dataSource', 'leftParentCellCustomRowName']" label="行名称(左)">
      <jnpf-input v-model:value="dataSource.leftParentCellCustomRowName" placeholder="请输入" />
    </a-form-item>
    <a-form-item :name="['dataSource', 'leftParentCellCustomColName']" label="列名称(左)">
      <jnpf-input v-model:value="dataSource.leftParentCellCustomColName" placeholder="请输入" />
    </a-form-item>
  </template>
  <a-form-item :name="['dataSource', 'topParentCellType']" label="上父格">
    <jnpf-select v-model:value="dataSource.topParentCellType" :options="cellTypeOptions" />
  </a-form-item>
  <template v-if="dataSource.topParentCellType === 'custom'">
    <a-form-item :name="['dataSource', 'topParentCellCustomRowName']" label="行名称(上)">
      <jnpf-input v-model:value="dataSource.topParentCellCustomRowName" placeholder="请输入" />
    </a-form-item>
    <a-form-item :name="['dataSource', 'topParentCellCustomColName']" label="列名称(上)">
      <jnpf-input v-model:value="dataSource.topParentCellCustomColName" placeholder="请输入" />
    </a-form-item>
  </template>
</template>

<script setup lang="ts">
  defineProps(['dataSource', 'dataSetList']);

  const summaryTypeOptions = [
    { id: 'none', fullName: '无' },
    { id: 'sum', fullName: '合计' },
    { id: 'max', fullName: '最大值' },
    { id: 'min', fullName: '最小值' },
    { id: 'count', fullName: '计数' },
    { id: 'avg', fullName: '平均值' },
  ];
  const polymerizationTypeOptions = [
    { id: '1', fullName: '列表' },
    { id: '2', fullName: '分组' },
    { id: '3', fullName: '汇总' },
  ];
  const cellTypeOptions = [
    { id: 'none', fullName: '无' },
    { id: 'default', fullName: '默认' },
    { id: 'custom', fullName: '自定义' },
  ];
</script>
